home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload Trio 2
/
Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO
/
dir36
/
tsbat46.zip
/
SWEEP.BAT
< prev
next >
Wrap
DOS Batch File
|
1994-01-13
|
3KB
|
94 lines
@echo off
echo ┌──────────────────────────────────────────────────────┐
echo │ SWEEP, Perform a command on a directory and below it │
echo │ A batch demo by Prof. Timo Salmi Thu 13-Jan-94 │
echo │ Draws on ideas of A.Reyes from PC-Mag Vol 12 No 19 │
echo └──────────────────────────────────────────────────────┘
rem Is help needed
if "%2"=="" goto _help
rem Put the names of the auxiliary files into environment variables.
rem Edit the dir_ to point where you put this batch. But note that
rem it is essential that the directory is at your path.
set dir_=c:\dos
set enter_=%dir_%\enter.com
set bat_=%dir_%\sweep$$$.bat
set dat_=%dir_%\sweep$$$.dat
set new_=%dir_%\new.bat
rem The loadfix.com command can run any program including "Enter"
if not exist c:\dos\loadfix.com goto _nofix
copy c:\dos\loadfix.com %enter_% > nul
Rem Build an auxiliary file for performing the command on one subdirectory
echo @echo off > %new_%
echo if "%%3"=="" goto _out >> %new_%
rem This is the crucial line. It has to command you wish to sweep with!
rem Since this is just a demonstration I have put dir/w in there, but
echo dir/w %%3\%2 >> %new_%
echo :_out >> %new_%
rem Build a list of the directories on the directory and its subdirectories
rem MsDos 5+ is required since dir does not have all the switches afore
dir %1 /b /s /a:d > %dat_%
echo %1 >> %dat_%
echo. >> %dat_%
rem Build a file with "Enter" commands, to be run by loadfix
echo @echo off > %bat_%
date < %dat_% | find "Enter" | sort /r >> %bat_%
rem Run the set of "Enter" commands
call %bat_%
rem Delete the auxiliary files
if exist %enter_% del %enter_%
if exist %bat_% del %bat_%
if exist %dat_% del %dat_%
if exist %new_% del %new_%
goto _out
:_nofix
echo File c:\dos\loadfix.com needed, but not found
goto _out
:_help
echo @echo off> ms-dos.bat
echo set ver_=%%2> ms-dos.bat
ver> tmp$$$.bat
echo Usage: SWEEP UpmostDirectory FileMask
echo.
echo Example: SWEEP C: *.BAK (*NOT* SWEEP C:\ *.BAK, i.e. don't end with \)
echo.
echo Draws heavily on the ideas by Arneil P. Reyes in PC-Mag Vol 12 No 19.
echo Also has several twists and improvements on my own like not requiring
echo sweep.bat itself being at the path, showing the MsDos version,
echo documentation within the batch, handling the upmost directory, etc.
echo.
echo Basically this batch answers the following FAQ (Frequently Asked
echo Question). How can one sweep a directory and all its subdirectories
echo with ordinary batch and MsDos commands only.
echo.
echo Requires at least MsDos 5.00
call tmp$$$
echo You seem to have MsDos version %ver_%
if exist tmp$$$.bat del tmp$$$.bat
if exist ms-dos.bat del ms-dos.bat
echo.
echo This is more of a demo than a production batch but it can be adjusted.
echo The line to change is "echo dir/w %%%%3\%%2 >> %%new_%%"
rem Note two tricks above, the quotes and the double percentage signs
echo by replacing dir/w by any commands you wish to sweep with.
goto _out
:_out
set dir=_
set bat_=
set dat_=
set enter_=
set new_=
set ver_=